package com.linxianqin.restTemplate.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.HashMap;

/**
 * @author lxq
 * @version 1.0
 * @description: 通过 restTemplate 发送delete请求
 * @date 2021/1/14 16:36
 */
@Slf4j
@RestController
public class DeleteController {
    private RestTemplate restTemplate;
    public DeleteController(RestTemplate restTemplate){
        this.restTemplate=restTemplate;
    }

    @GetMapping("/delete")
    public void delete(){
        String url="http://localhost:8080/test/delete";
        HashMap<String, Object> params = new HashMap<>();
        params.put("username","admin");
        log.info("消费端通过restTemplate 发送delete请求");
        restTemplate.delete(url+"/{1}",1);
    }

}
